/*
 * Copyright (c) 2023, mr-library Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2023-04-23     billy       first version
 */

#ifndef _LCD_H_
#define _LCD_H_

#include "mrapi.h"

#ifdef __cplusplus
extern "C" {
#endif

#if (MR_CFG_LCD == MR_CFG_ENABLE)

/**
 * @def Serial device default config
 */
#define MR_LCD_CONFIG_DEFAULT   \
{                               \
    0,              \
    0,              \
    0,              \
    0,              \
    0,              \
    0,              \
}

/**
 * @struct Lcd device config
 */
struct mr_lcd_config
{
    mr_uint32_t depth;
    mr_uint32_t bus;
    mr_uint32_t x_res;
    mr_uint32_t y_res;
    mr_uint32_t power;
    mr_uint32_t backlight;
};
typedef struct mr_lcd_config *mr_lcd_config_t;

typedef struct mr_lcd *mr_lcd_t;

/**
 * @struct Lcd device operations
 */
struct mr_lcd_ops
{
    mr_err_t (*configure)(mr_lcd_t lcd, mr_lcd_config_t config);
    void (*write)(mr_lcd_t lcd, void *buf, void *area, void *color_p);
    mr_uint8_t (*read)(mr_lcd_t lcd);
};

/**
 * @struct Lcd device
 */
struct mr_lcd
{
    struct mr_device device;

    struct mr_lcd_config config;

    const struct mr_lcd_ops *ops;
};

/**
 * @addtogroup Lcd device
 * @{
 */
mr_err_t mr_lcd_device_add(mr_lcd_t lcd, const char *name, struct mr_lcd_ops *ops, void *data);
/** @} */

#endif

#ifdef __cplusplus
}
#endif

#endif /* _LCD_H_ */